#include<bits/stdc++.h>
#define int unsigned int
using namespace std;
const int N = 1005;
int n,m,a[N],b[N],c[N],d[N];
signed main()
{
	freopen("c.in","r",stdin);
	freopen("c.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i = 1;i<=m;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	int ans = 0;
	for(int x = 1;x<=n;x++)
		for(int y = 1;y<=n;y++)
			for(int z = 1;z<=n;z++)
				for(int l = 1;l<=n;l++)
				{
					bool fl = 1;
					for(int i = 1;i<=m&&fl;i++) fl&=(((x>a[i])+(y>b[i])+(z>c[i])+(l>d[i]))>=3);
					ans+=fl;
				}
	cout<<ans;
	return 0;
}

